var PITCHWISE = PITCHWISE || {};
PITCHWISE.pitch = PITCHWISE.pitch || {};
PITCHWISE.pitch.slots = PITCHWISE.pitch.slots || {};

PITCHWISE.pitch.slots = function (options) {
    'use strict';

    //this.authenticated = options.authenticated;
    this.el = {
        'date':$('#select-slot')
    };

    console.log('PITCHWISE.pitch.slots.options', options);
    this.load();
};
PITCHWISE.pitch.slots.prototype.events = function () {
    var _this = this;

    this.el.date.on('change', function () {
        var val = _this.el.date.val().split("-");
        $('#booking-table form [name=day]').val(val[1]);
        $('#booking-table form [name=date]').val(val[0]);
        var that;
        var count = false;
        $('#booking-table tr').each(function (e) {
            that = this;
            if (count) {
                $(this).hide();
                if ($(that).attr("data-day").indexOf(val[1]) !== -1) {
                    $(that).show();
                }
            }
            count = true;

        });
    });
};
PITCHWISE.pitch.slots.prototype.init = function () {
    this.el.date.trigger('change');
};

PITCHWISE.pitch.slots.prototype.load = function () {
    this.events();
    this.init();
};